﻿using System; 
using System.Windows.Forms;

namespace GetMonsterHp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            BindVal();
        }


        private void BindVal()
        {
            //初始化地图 
            comboBox1.Items.Clear();

            comboBox1.Items.Add(new BossList(1, 150, 1, "冒险者之森"));
            comboBox1.Items.Add(new BossList(2, 150, 3, "英雄之村"));
            comboBox1.Items.Add(new BossList(3, 150, 7, "遗落圣坛"));
            comboBox1.Items.Add(new BossList(4, 150, 10, "废弃边陲"));
            comboBox1.Items.Add(new BossList(5, 150, 16, "古代竞技场"));
            comboBox1.Items.Add(new BossList(6, 150, 20, "低语之森"));
            comboBox1.Items.Add(new BossList(7, 150, 25, "圣者之塔"));
            comboBox1.Items.Add(new BossList(8, 150, 30, "砂漠绿洲"));
            comboBox1.Items.Add(new BossList(9, 150, 35, "血腥要塞"));
            comboBox1.Items.Add(new BossList(10, 150, 40, "德古拉城堡"));
            comboBox1.Items.Add(new BossList(1001, 150, 20, "海贼之港"));
            comboBox1.Items.Add(new BossList(1002, 150, 25, "骷髅岛"));
            comboBox1.Items.Add(new BossList(1003, 150, 37, "蒸汽之都"));
            comboBox1.Items.Add(new BossList(1004, 150, 33, "阿瓦隆要塞"));
            comboBox1.Items.Add(new BossList(1005, 150, 40, "地狱边境"));
            comboBox1.Items.Add(new BossList(1006, 150, 46, "混沌深渊"));

            if (comboBox1.Items.Count > 0)
                comboBox1.SelectedIndex = 0;
        }

        private int GetBossHp(double hpCoef, int layer, double layerFix)
        {
            double hp_b = 0.7 * layerFix;
            double hp_a = hpCoef * (60 + layerFix) / 800;
            double max_hp = 0;

            if (layer < 30)
            {
                double num = 5600 * layerFix + (int)(10 * (60 + layerFix) * hpCoef * layer);
                double deno = 8000;
                int ret = (int)(num / deno);
                if (num % deno != 0)
                    ret = ret + 1;
                return ret;
            }
            else if (layer < 35)
            {
                max_hp = hp_b + hp_a * layer * layer / 30;
            }
            else if (layer < 55)
            {
                max_hp = hp_b + hp_a * layer * layer / 30 * layer / 35;
            }
            else if (layer < 75)
            {
                max_hp = hp_b + hp_a * layer * layer / 30 * layer / 35 * layer / 55;
            }
            else
            {
                max_hp = hp_b + hp_a * layer * layer / 30 * layer / 35 * layer / 55 * layer / 75;
            }
            return (int)Math.Ceiling(max_hp);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            var lis = comboBox1.SelectedItem as BossList;

            var hpCoef = Convert.ToDouble(lis.HpCoef);
            var layer = Convert.ToInt32(txt_layer.Text.Trim());
            var layerFix = Convert.ToDouble(lis.LayerFix);


            richTextBox1.Clear();

            for (int i = 3; i <= layer / 10; i++)
            {
                var MaxHp = GetBossHp(hpCoef, i * 10, layerFix);
                richTextBox1.AppendText(string.Format("{0}层，Boss血量：{1}", i * 10, MaxHp) + "\r\n");
            }
        }


        /// <summary>
        /// 地图对象
        /// </summary>
        public class BossList
        {
            /// <summary>
            /// 地图ID
            /// </summary>
            public int ClassId { get; set; }
            /// <summary>
            /// HP系数
            /// </summary>
            public double HpCoef { get; set; }
            /// <summary>
            /// 迷宫系数
            /// </summary>
            public double LayerFix { get; set; }
            /// <summary>
            /// 迷宫名称
            /// </summary>
            public string Name { get; set; }

            /// <summary>
            /// 实例化地图对象
            /// </summary>
            /// <param name="strID">地图ID</param>
            /// <param name="strHpCoef">HP系数</param>
            /// <param name="strLayerFix">迷宫系数</param>
            /// <param name="strName">迷宫名称</param>
            public BossList(int strID, double strHpCoef, double strLayerFix, string strName)
            {
                this.ClassId = strID;
                this.Name = strName;
                this.LayerFix = strLayerFix;
                this.HpCoef = strHpCoef;
            }
            public override string ToString() { return this.Name; }
        }

    }
}
